package com.project.service.Impl;

import com.project.handlChain.TakewayRiderHandleChain;
import com.project.mapper.RiskControllerMapper;
import com.project.pojo.RiskController;
import com.project.service.TakewayRiderService;
import com.project.utils.ErrorMessage;
import com.project.vo.TakewayRiderMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class TakewayRiderServiceImpl implements TakewayRiderService {

    private List<RiskController> list=new ArrayList<>();

    List<ErrorMessage> errorMessageList=new ArrayList<>();

    @Autowired
    TakewayRiderHandleChain takewayRiderHandleChain;

    @Autowired
    RiskControllerMapper riskControllerMapper;

    @Override
    public List<ErrorMessage> takewayRiderRiskAssess(TakewayRiderMessage takewayRiderMessage) {
        list=riskControllerMapper.getByInsuranceTypeRiskControllers(2);
        takewayRiderHandleChain.handle(takewayRiderMessage,list,errorMessageList);
        if(errorMessageList.size()>0){
            return errorMessageList;
        }
        return null;
    }
}
